package cn.shengchao.examstar.product.ohs.remote.rpc;

import cn.shengchao.examstar.rpc.base.PageResult;
import cn.shengchao.examstar.rpc.product.api.IProductUserOrderExpiredRpc;
import cn.shengchao.examstar.rpc.product.req.ProductUserOrderExpiredPageQuery;
import cn.shengchao.examstar.rpc.product.res.ProductUserOrderExpiredVo;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

/**
 * @program: examstarapi
 * @description: 用户产品有效期
 * @author: Xiong weiqiang
 * @create: 2025-06-30 17:38
 */
@DubboService
public class ProductUserOrderExpiredRpc implements IProductUserOrderExpiredRpc {
    @Autowired
    private cn.shengchao.examstar.product.acl.ports.repositories.IProductUserOrderExpiredRepository productUserOrderExpiredRepository;
    @Override
    public PageResult<ProductUserOrderExpiredVo> queryUserOrderExpired(ProductUserOrderExpiredPageQuery query) {
        try(Page<Object> page= PageHelper.startPage(query.getPage(), query.getSize())){
            List<ProductUserOrderExpiredVo> list =productUserOrderExpiredRepository.pageList(query);
            return PageResult.of(page.getTotal(), list);
        }
    }
}